package cn.pxy.ysframework.web.Service.Impl;

import cn.pxy.ysframework.web.Entity.Account;
import cn.pxy.ysframework.web.Entity.Card;
import cn.pxy.ysframework.web.Entity.Category;
import cn.pxy.ysframework.web.Repository.ICardDao;
import cn.pxy.ysframework.web.Service.ICardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

@Service
public class CardService implements ICardService {
    @Autowired
    private ICardDao cardDao;

    public Card save(Card card){
        return cardDao.save(card);
    }

    public Page<Card> findAllCardWithPager(int page, int num) {
        Pageable pageable = PageRequest.of(page,num, Sort.Direction.DESC,"sort");
        return cardDao.findAll(pageable);
    }

    @Override
    public Card findById(String id) {
        return cardDao.findById(id).get();
    }
}
